<template>
  <div>
  <el-table
      :data="tableData"
      style="width: 100%">
    <el-table-column type="expand">
      <template slot-scope="props">
        <el-form label-position="left" inline class="demo-table-expand">
          <el-form-item label="发布人">
            <span>{{ props.row.comId }}</span>
          </el-form-item>
          <el-form-item label="公告内容">
            <span>{{ props.row.content }}</span>
          </el-form-item>
        </el-form>
      </template>
    </el-table-column>
    <el-table-column
        label="发布id"
        prop="id">
    </el-table-column>
    <el-table-column
        label="公告标题"
        prop="noticeTitle">
    </el-table-column>
    <el-table-column
        label="发布时间"
        prop="publishDate">
    </el-table-column>
  </el-table>


<!--  <div style="float: right;margin-top: 10px">-->
<!--    <el-pagination-->
<!--        background-->
<!--        layout="prev, pager, next"-->
<!--        :page-size="pageSize"-->
<!--        :total="total"-->

<!--        @current-change="mypage">-->
<!--    </el-pagination>-->
<!--  </div>-->
  </div>


</template>

<script>
import axios from 'axios'

function getComid() {
  var that = this
  axios.get('http://localhost:8080/jas/sport/student/getComidByStudent/'+this.sno).then(function (resp) {
    that.comId = resp.data
    console.log("comid"+resp.data)
  })
  console.log("comidsasasasassasasas"+this.comId)
}

export default {
  name: "AnnounceMainPage",
  data(){
    return{
      sno: sessionStorage.getItem("sno"),
      comId: '',
      pageSize: 5,
      total: 10,
      formForSearch: {
        publishDate: '',
        noticeTitle: ''
      },
      tableData: null
    }
  },
  // created(){
  //   // getComid()
  //    var _this = this
  //   axios.get('http://localhost:8080/jas/sport/notice/getNoticeWithoutId').then(function (resp) {
  //     _this.tableData = resp.data
  //   })
  // },
  mounted(){
    var _this = this
    axios.get('http://localhost:8080/jas/sport/notice/getNoticeWithoutId/'+'1/5').then(function (resp) {
      console.log(resp.data)
      _this.tableData = resp.data
    })
  },
  methods: {

    handleSelectionChange(val) {
      this.multipleSelection = val;
      // console.log(val)
    },
    //table中的
    // mypage (currentpage) {
    //   const _this = this
    //   axios.get('http://localhost:8080/jas/mport/notice/getNoticeWithoutId/'+currentPage +'/' +_this.pageSize).then(function (resp) {
    //     _this.tableData = resp.data
    //   })
    // },
    viewById(row){
      this.$router.push({name:'ViewNoticeDetail',params:{noticeId:row.id}})
    },
    search() {
      if (this.formForSearch.publishDate!='' || this.formForSearch.noticeTitle!=''){
        var _this = this
        var form = new FormData()

        form.append('account',this.account)
        // form.append('publishDate',this.formForSearch.publishDate)
        form.append('noticeTitle',this.formForSearch.noticeTitle)
        axios.post('http://localhost:8080/jas/mport/notice/getNoticesForSearch',form).then(function (resp) {
          const noticeList = resp.data
          if (noticeList.length > 0){
            _this.$router.push({name:'ViewNotice',params:{notices:noticeList}})
          } else {
            alert("没有符合条件的查询")
          }

        })
      } else {
        alert('请输入查询条件')
      }

    }
  }
}
</script>



<style lang="scss" scoped>
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>